<?php $this->load->view('admin/' . $this->router->fetch_class() . '/_script'); ?>
<?php $this->load->view('admin/' . $this->router->fetch_class() . '/_editor'); ?>
<li>
  <label for="title">
    <?php echo $this->lang->line('label.promotion.title') ?><span>*</span> / 
    <?php echo $this->lang->line('label.promotion.code') ?><span>*</span>
  </label>
  <div class="input">
    <input type="text" id="title" value="<?php echo empty($obj["title"]) ? "" : $obj["title"] ?>" name="title">
    <input type="text" id="code" value="<?php echo empty($obj["code"]) ? "" : $obj["code"] ?>" name="code">
  </div>
</li>
<li>
  <label for="description"><?php echo $this->lang->line('label.promotion.description') ?><span>*</span></label>
  <br style="clear:both">
  <textarea class="wysiwyg-advanced" rows="10" cols="40" name="description" id="description"><?php echo empty($obj["description"]) ? "" : $obj["description"] ?></textarea>
</li>
<li>
  <label for="category"><?php echo $this->lang->line('label.promotion.category') ?><span>*</span></label>
  <div class="input">
    <select id="category" name="category[]" class="chzn chzn-done" 
            multiple="multiple"
            style="visibility: visible;">
      <option value="0" >
        <?php echo $this->lang->line('label.option.select') ?>
      </option>
      <?php
      $ref_objs = $this->category_model->get_all_tree();
      foreach ($ref_objs as $ref) {
        ?>
        <option value="<?php echo $ref["id"] ?>"
                <?php echo in_array($ref["id"], $category) ? 'selected="selected"' : '' ?>>
                  <?php echo $this->category_model->to_string($ref) ?>
        </option>
      <?php } ?>
    </select>
  </div>
</li>
<?php if (empty($provider_id)) { ?>
  <li>
    <label for="provider_user_id"><?php echo $this->lang->line('label.promotion.provider_user_id') ?><span>*</span></label>
    <div class="input">
      <select id="provider_user_id" name="provider_user_id" class="chzn chzn-done" style="visibility: visible;">
        <option value="0">
          <?php echo $this->lang->line('label.option.select') ?>
        </option>
        <?php
        $ref_objs = $this->provider_user_model->get_all();
        foreach ($ref_objs as $ref) {
          ?>
          <option value="<?php echo $ref["id"] ?>"
                  <?php echo empty($obj["provider_user_id"]) || $obj["provider_user_id"] != $ref["id"] ? "" : 'selected="selected"' ?>>
                    <?php echo $this->provider_user_model->to_string($ref) ?>
          </option>
        <?php } ?>
      </select>
    </div>
  </li>
<?php } else { ?>
  <input type="hidden" value="<?php echo $provider_id ?>" name="provider_user_id"/>
<?php } ?>
<li>
  <label for="start_date">
    <?php echo $this->lang->line('label.promotion.start_date') ?><span>*</span> / 
    <?php echo $this->lang->line('label.promotion.end_date') ?><span>*</span>
  </label>
  <div class="input">
    <input type="text" id="start_date" name="start_date"
           value="<?php echo empty($obj["start_date"]) ? date($this->setting_model->item('date_format')) : $obj["start_date"] ?>" >
    <input type="text" id="end_date" 
           value="<?php echo empty($obj["end_date"]) ? date($this->setting_model->item('date_format')) : $obj["end_date"] ?>" name="end_date">
  </div>
</li>
<li>
  <label for="status"><?php echo $this->lang->line('label.promotion.status') ?></label>
  <div class="input">
    <select id="status" name="status" class="chzn chzn-done" style="visibility: visible;">
      <?php
      $status = array(
          PROMOTION_NEW => $this->lang->line('label.promotion.status.new'),
          PROMOTION_PEDDING => $this->lang->line('label.promotion.status.pedding'),
          PROMOTION_APPROVED => $this->lang->line('label.promotion.status.approve'),
          PROMOTION_PUBLISH => $this->lang->line('label.promotion.status.publish'),
          PROMOTION_REJECT => $this->lang->line('label.promotion.status.reject'),
          PROMOTION_BLOCK => $this->lang->line('label.promotion.status.block'));
      foreach ($status as $value => $label) {
        ?>
        <option value="<?php echo $value ?>"
                <?php echo empty($obj["status"]) || $obj["status"] != $value ? "" : 'selected="selected"' ?>>
                  <?php echo $label ?>
        </option>
      <?php } ?>
    </select>
  </div>
</li>
<li>
  <label for="country_id">
    <?php echo $this->lang->line('label.promotion.country_id') ?><span>*</span> / 
    <?php echo $this->lang->line('label.promotion.state_id') ?><span>*</span> / 
    <?php echo $this->lang->line('label.promotion.city_id') ?><span>*</span>
  </label>
  <div class="input">
    <select id="country_id" name="country_id" class="chzn chzn-done" style="visibility: visible;">
      <option value="0">
        <?php echo $this->lang->line('label.option.select') ?>
      </option>
      <?php
      $ref_objs = $this->country_model->get_all();
      foreach ($ref_objs as $ref) {
        ?>
        <option value="<?php echo $ref["id"] ?>"
                <?php echo empty($obj["country_id"]) || $obj["country_id"] != $ref["id"] ? "" : 'selected="selected"' ?>>
                  <?php echo $this->country_model->to_string($ref) ?>
        </option>
      <?php } ?>
    </select>
    <select id="state_id" name="state_id" class="chzn chzn-done" style="visibility: visible;">
      <option value="0">
        <?php echo $this->lang->line('label.option.select') ?>
      </option>
    </select>
    <select id="city_id" name="city_id" class="chzn chzn-done" style="visibility: visible;">
      <option value="0">
        <?php echo $this->lang->line('label.option.select') ?>
      </option>
    </select>
  </div>
</li>
<li>
  <label for="lat">
    <?php echo $this->lang->line('label.promotion.lat') ?>
    <?php echo $this->lang->line('label.promotion.lng') ?>
  </label>
  <div class="input">
    <input type="text" id="lat" value="<?php echo empty($obj["lat"]) ? "" : $obj["lat"] ?>" name="lat">
    <input type="text" id="lng" value="<?php echo empty($obj["lng"]) ? "" : $obj["lng"] ?>" name="lng">
  </div>
</li>
<li>
  <label for="map">&nbsp;</label>
  <div class="input">
    <div id="map" style="width: 460px;height:200px;"></div>
  </div>
</li>
<li>
  <label for="max_download">
    <?php echo $this->lang->line('label.promotion.max_download') ?><span>*</span> / 
    <?php echo $this->lang->line('label.promotion.max_per_person') ?><span>*</span>
  </label>
  <div class="input">
    <input type="text" id="max_download" value="<?php echo empty($obj["max_download"]) ? 1 : $obj["max_download"] ?>" name="max_download">
    <input type="text" id="max_per_person" value="<?php echo empty($obj["max_per_person"]) ? 1 : $obj["max_per_person"] ?>" name="max_per_person">
  </div>
</li>
<li>
  <label for="support_channel"><?php echo $this->lang->line('label.promotion.support_channel') ?></label>
  <div class="input">
    <select id="support_channel" name="support_channel" class="chzn chzn-done" style="visibility: visible;">
      <?php
      $support_channel = array(
          PROMOTION_CHANNEL_ALL => $this->lang->line('label.promotion.support_channel.all'),
          PROMOTION_CHANNEL_EMAIL => $this->lang->line('label.promotion.support_channel.email'),
          PROMOTION_CHANNEL_SMS => $this->lang->line('label.promotion.support_channel.sms'));
      foreach ($support_channel as $value => $label) {
        ?>
        <option value="<?php echo $value ?>"
                <?php echo empty($obj["support_channel"]) || $obj["support_channel"] != $value ? "" : 'selected="selected"' ?>>
                  <?php echo $label ?>
        </option>
      <?php } ?>
    </select>
  </div>
</li>
<li>
  <label for="support_encode">
    <?php echo $this->lang->line('label.promotion.support_encode') ?>
  </label>
  <div class="input">
    <select id="support_encode" name="support_encode" class="chzn chzn-done" style="visibility: visible;">
      <?php
      $support_encode = array(
          PROMOTION_ENCODE_ALL => $this->lang->line('label.promotion.support_encode.all'),
          PROMOTION_ENCODE_BARCODE => $this->lang->line('label.promotion.support_encode.barcode'),
          PROMOTION_ENCODE_TEXT => $this->lang->line('label.promotion.support_encode.text'));
      foreach ($support_encode as $value => $label) {
        ?>
        <option value="<?php echo $value ?>"
                <?php echo empty($obj["support_encode"]) || $obj["support_encode"] != $value ? "" : 'selected="selected"' ?>>
                  <?php echo $label ?>
        </option>
      <?php } ?>
    </select>
  </div>
</li>
<li>
  <label for="is_hot">
    <?php echo $this->lang->line('label.promotion.is_hot') ?>
  </label>
  <div class="input">
    <input type="checkbox" id="is_hot" value="1" name="is_hot" 
           <?php echo isset($obj["is_hot"]) && $obj["is_hot"] ? 'checked="checked"' : "" ?>>
  </div>
</li>
<li>
  <label><?php echo $this->lang->line('label.promotion.is_active') ?></label>
  <div class="input">
    <input type="checkbox" id="is_active" value="1" name="is_active" 
           <?php echo isset($obj["is_active"]) && $obj["is_active"] ? 'checked="checked"' : "" ?>>
  </div>
</li>